package com.phz.springcloud.study.client;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 淘宝ip库
 * @Auther: penghaozhong
 * @Date: 2018/9/13 10:35
 */
@FeignClient(url = "${ip.taobao}",name = "ipTaobaoClient",fallback = IpTaobaoClient.DefaultFallback.class)
public interface IpTaobaoClient {


    @RequestMapping(
            value = {"/service/getIpInfo.php"},
            method = {RequestMethod.GET}
    )
    String findCity(@RequestParam("ip") String ip);


    @Component
    @Slf4j
    class DefaultFallback implements IpTaobaoClient {

        @Override
        public String findCity(String ip) {
            log.error("淘宝ip库服务不可用");
            return null;
        }
    }


}
